package com.pointcircle.core.web.auth;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.pointcircle.core.entity.User;

public class AuthUtils {
	
	private static final String VALIDATE_CODE_KEY = "VALIDATE_CODE_KEY";
		
	public static User getUser() {
		Subject subject = SecurityUtils.getSubject();
		User user = (User) subject.getPrincipal();
		return user;
	}
	
	public static void putValidateCode(String validateCode) {
		Session session = SecurityUtils.getSubject().getSession();
		session.setAttribute(VALIDATE_CODE_KEY, validateCode);
	}
	
	public static String getValidateCode() {
		Session session = SecurityUtils.getSubject().getSession();
		return (String) session.getAttribute(VALIDATE_CODE_KEY);
	}
}
